﻿using Abp.Application.Services.Dto;
using Abp.Domain.Repositories;
using Abp.Domain.Services;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;


namespace LeadThing.AbpZeroTemplate.DisputeInformations
{
    /// <summary>
    /// 矛盾纠纷信息业务管理
    /// </summary>
    public class DisputeInformationManage : IDomainService
    {
        private readonly IRepository<DisputeInformation, long> _disputeInformationRepository;

        /// <summary>
        /// 构造方法
        /// </summary>
        public DisputeInformationManage(IRepository<DisputeInformation, long> disputeInformationRepository)
        {
            _disputeInformationRepository = disputeInformationRepository;
        }

        //TODO:编写领域业务代码

        /// <summary>
        /// 获取所有纠纷来源
        /// </summary>
        /// <returns></returns>
        public List<ComboboxItemDto> GetAllDisSourceList()
        {
            List<ComboboxItemDto> List = new List<ComboboxItemDto>();
            Type t = typeof(DisSource);
            Array arrays = Enum.GetValues(t);

            for (int i = 0; i < arrays.LongLength; i++)
            {
                DisSource test = (DisSource)arrays.GetValue(i);
                FieldInfo fieldInfo = test.GetType().GetField(test.ToString());
                object[] attribArray = fieldInfo.GetCustomAttributes(false);

                ComboboxItemDto model = new ComboboxItemDto()
                {
                    Value = Convert.ToInt32(arrays.GetValue(i)).ToString(),
                    DisplayText = ((DescriptionAttribute)attribArray[0]).Description
                };
                List.Add(model);
            }

            return List;
        }

        /// <summary>
        /// 获取所有紧急程度
        /// </summary>
        /// <returns></returns>
        public List<ComboboxItemDto> GetAllDisUrgencyList()
        {
            List<ComboboxItemDto> List = new List<ComboboxItemDto>();
            Type t = typeof(DisUrgency);
            Array arrays = Enum.GetValues(t);

            for (int i = 0; i < arrays.LongLength; i++)
            {
                DisUrgency test = (DisUrgency)arrays.GetValue(i);
                FieldInfo fieldInfo = test.GetType().GetField(test.ToString());
                object[] attribArray = fieldInfo.GetCustomAttributes(false);

                ComboboxItemDto model = new ComboboxItemDto()
                {
                    Value = Convert.ToInt32(arrays.GetValue(i)).ToString(),
                    DisplayText = ((DescriptionAttribute)attribArray[0]).Description
                };
                List.Add(model);
            }

            return List;
        }


        /// <summary>
        ///     初始化
        /// </summary>
        private void Init()
        {

        }
    }
}
